version 14
clear
set more off
set matsize 5000
pwd

********** Merge on parent info from tax year relevant to birthdate cutoff **********
use pik taxyr_cut cutyr belowcut z pik_key_parent /* dad_age*/ mom_age *parent_fil_stat parent_maxage birth_order* /*sib_count*/ /*parent_sched_se*/ i_obstaxyr *parent_have_1040 i_*eitc* *deitc* *agi* *dtax* *parent_mafid* dob_dow pob_fips male us_born using ${clean_data}/taxyrcut_parents_small

********** Clean up variable names **********
do ${main}/dos/tax/build/build_support/kid_parentvar_cleanup_full.do

gen i_k1 = (birth_order==1)

merge 1:1 pik using  ${raw_data}/birth_county, gen(_m_kpob) keepusing(pob_st_fips pob_co_fips) keep(match master)
rename pob_st_fips kpob_st_fips
rename pob_co_fips kpob_co_fips
destring kpob_st_fips, force replace
destring kpob_co_fips, force replace

rename kpob_st_fips state_fips
rename kpob_co_fips county_fips
merge m:1 state_fips county_fips using  ${supp_data}/county_chars1980, gen(_m_kpobchar) keepusing(smsaa c80*) keep(match master)
rename  state_fips kpob_st_fips
rename  county_fips kpob_co_fips
foreach x of varlist smsaa c80* {
		rename `x' kpob`x'
}

save ${clean_data}/taxtax_pobchars, replace
